package ex_from_web;



public class thread_sleep {

	    public static void main(String[] args) {
	        long start;
	        long end;
	        for (int i=0; i<50; i++) {
	            start = System.nanoTime();
	            try {
	                Thread.sleep(500); //sleep for about 1s
	            } catch (InterruptedException e) {
	                System.out.println("Thread was interrupted!");
	            }
	            end = System.nanoTime();
	            System.out.println("Sleep duration " + ((double)(end - start) / 1000000) + " ms");
	        }
	    }

	}